package com.chaos.auth.service.userdetails;

import com.chaos.auth.api.data.RbacUserData;
import com.chaos.auth.service.RbacUserRoleService;
import com.chaos.auth.service.auth.BaseUserDetailsService;
import com.chaos.auth.exception.PhoneNotFoundException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Set;

/**
 * @author yjp
 * @date 2024/5/30
 */
@Slf4j
@Component
public class AdminByPhoneDetailsService implements BaseUserDetailsService {

    @Resource
    private AdminDetailsService adminDetailsService;


    @Override
    public UserDetails loadUserByPhone(String phone, Long tenantId) throws PhoneNotFoundException {
        RbacUserData rbacUser = adminDetailsService.getRbacUserDataByPhone(phone, tenantId);
        return adminDetailsService.getAdminUserDetails(rbacUser);
    }


}
